diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-08 10:12:31 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-08 10:12:31 +0700 |
| commit | 0ca62faf89775496320025c170c942b2cb3e1a20 (patch) | |
| tree | 4107119c58e82aedf3478c165741824ff9cd08c1 /src/pages/sitemap/products/[id].xml.js | |
| parent | e7383ff9601e47953c732fccf093e19993ec37cd (diff) | |
update theme color
Diffstat (limited to 'src/pages/sitemap/products/[id].xml.js')
| -rw-r--r-- | src/pages/sitemap/products/[id].xml.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/pages/sitemap/products/[id].xml.js b/src/pages/sitemap/products/[id].xml.js new file mode 100644 index 00000000..e9caaa00 --- /dev/null +++ b/src/pages/sitemap/products/[id].xml.js @@ -0,0 +1,32 @@ +import productSearchApi from '@/lib/product/api/productSearchApi' +import { create } from 'xmlbuilder' +import _ from 'lodash-contrib' +import { createSlug } from '@/core/utils/slug' + +export async function getServerSideProps({ res }) { + const baseUrl = process.env.SELF_HOST + '/shop/product' + const limit = 2500 + const query = { limit } + const products = await productSearchApi({ query: _.toQuery(query) }) + console.log(products); + // const sitemap = create('urlset', { encoding: 'UTF-8' }) + + // const date = new Date() + // pages.forEach((page) => { + // const url = sitemap.ele('url') + // url.ele('loc', createSlug(baseUrl, '', '')) + // url.ele('lastmod', date.toISOString().slice(0, 10)) + // url.ele('changefreq', 'weekly') + // url.ele('priority', '0.8') + // }) + + // res.setHeader('Content-Type', 'text/xml') + // res.write(sitemap.end()) + // res.end() + + return { props: {} } +} + +export default function SitemapProducts() { + return <></> +} |
